$("#leave").click(function () {
    //加载数据
    $(".msgHtml").html("");
    $.ajax({
        url: "selectLetter/"+ $("#hId").val() ,
        post:"GET",
        success :function(result){
            console.log(result);
            var msgHtml = '';
            data = result.extend.letterList;
            for(var i=0; i<data.length; i++){
                msgHtml += '<tr>';
                msgHtml += '  <td class="msg_info">';
                msgHtml += '    <img src="'+data[i].writerUser.picture+'" width="50" height="50"><input type="hidden" value="'+data[i].letterId+'">';
                msgHtml += '    <div class="user_info">';
                msgHtml += '        <h2 style="font-size: 15px">'+data[i].writerUser.nickName+'</h2>';
                msgHtml += '        <p>'+data[i].content+'</p>';
                msgHtml += '    </div>';
                msgHtml += '  </td>';
                msgHtml += '  <td class="msg_time">'+data[i].sendTime+'</td>';
                msgHtml += '  <td class="msg_reply"></td>';
                msgHtml += '  <td class="msg_opr">';
                msgHtml += '    <a class="layui-btn layui-btn-mini layui-btn-normal msg_collect" onclick="isRead(this)"><i class="layui-icon">&#xe600;</i> 已读</a>';
                msgHtml += '    <a class="layui-btn layui-btn-mini reply_msg"><i class="layui-icon">&#xe611;</i> 回复</a>';
                msgHtml += '  </td>';
                msgHtml += '</tr>';
            }
            $(".msgHtml").html(msgHtml);
        }
    })
})


$("#system").click(function () {
    //加载数据
    $(".msgHtml").html("");
    $.ajax({
        url: "selectSystemLetter/"+ $("#hId").val() ,
        post:"GET",
        success :function(result){
            console.log(result);
            var msgHtml = '';
            data = result.extend.letterList;
            for(var i=0; i<data.length; i++){
                msgHtml += '<tr>';
                msgHtml += '  <td class="msg_info">';
                msgHtml += '    <img src="'+data[i].writerUser.picture+'" width="50" height="50"><input type="hidden" value="'+data[i].letterId+'">';
                msgHtml += '    <div class="user_info">';
                msgHtml += '        <h2 style="font-size: 15px">'+data[i].writerUser.nickName+'</h2>';
                msgHtml += '        <p>您的文章标题为:'+data[i].article.title+' 被退回,意见:'+data[i].content+'</p>';
                msgHtml += '    </div>';
                msgHtml += '  </td>';
                msgHtml += '  <td class="msg_time">'+data[i].sendTime+'</td>';
                msgHtml += '  <td class="msg_reply"></td>';
                msgHtml += '  <td class="msg_opr">';
                msgHtml += '    <a class="layui-btn layui-btn-mini layui-btn-normal msg_collect" onclick="reapply(this)"><i class="layui-icon">&#xe600;</i> 重新申请</a>';
                msgHtml += '  </td>';
                msgHtml += '</tr>';
            }
            $(".msgHtml").html(msgHtml);
        }
    })
})

function reapply(obj){
    var letterId = $(obj).parent().siblings().eq(0).find("input[type='hidden']").val();
    window.location.href ="reapply?letterId=" + letterId;
}